/*
 * SABaseContainer.cpp
 *
 *  Created on: 2010-06-04
 *      Author: NONO
 */

// SYSTEM INCLUDES
#include <AknsDrawUtils.h>                      // Skin
#include <AknsBasicBackgroundControlContext.h>  // Skin
#include <aknview.h>                            // CAknView
#include <eikmenub.h>                           // CEikMenuBar

// USER INCLUDES
#include "SAAppUi.h"

// CLASS INCLUDE
#include "SABaseContainer.h"

// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// Constructor, destructor
// ---------------------------------------------------------
CSABaseContainer::CSABaseContainer(CSAAppUi& aAppUi):
iSAAppUi(aAppUi)
{
}

void CSABaseContainer::ConstructL(const TRect& aRect)
{
    SetRect(aRect);
    ActivateL();
}

// Destructor
CSABaseContainer::~CSABaseContainer()
{
}


// ---------------------------------------------------------
// CSABaseContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CSABaseContainer::Draw(const TRect& aRect) const
{
    CWindowGc& gc = SystemGc();
    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
    MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
    AknsDrawUtils::Background(skin, cc, this, gc, aRect);
}

void CSABaseContainer::RedrawNow()
{
    SizeChanged();
    DrawNow();
}

//---------------------------------------------------------
// Menubar and softkey manipulation
//---------------------------------------------------------
void CSABaseContainer::ChangeViewMenuL(TUid aUid, TInt aResourceId)
{
    if (aUid != KNullUid)
    {
        CEikMenuBar* menuBar = iSAAppUi.View(aUid)->MenuBar();
        if (menuBar)
        {
            menuBar->SetMenuTitleResourceId(aResourceId);
        }
        else
        {
            User::Leave(KErrNotSupported);
        }
    }
}
